import { resultSuccess, doCustomTimes } from '../_util';

function getMenuKeys() {
  const keys = ['dashboard', 'console', 'workplace', 'basic-form', 'step-form', 'detail'];
  const newKeys = [];
  doCustomTimes(parseInt(Math.random() * 6), () => {
    const key = keys[Math.floor(Math.random() * keys.length)];
    newKeys.push(key);
  });
  return Array.from(new Set(newKeys));
}

const roleList = (pageSize) => {
  const result: any[] = [];
  doCustomTimes(pageSize, () => {
    result.push({
      id: '@integer(10,100)',
      name: '@cname()',
      explain: '@cname()',
      isDefault: '@boolean()',
      menu_keys: getMenuKeys(),
      create_date: `@date('yyyy-MM-dd hh:mm:ss')`,
      'status|1': ['normal', 'enable', 'disable'],
    });
  });
  return result;
};

const roleLists=[
    {
      "authArrs": [
        {
          "psDesc": "基础数据统计分析",
          "psId": 101,
          "psName": "数据",
          "psUrl": "/data"
        },
        {
          "psDesc": "游戏基础配置",
          "psId": 102,
          "psName": "游戏",
          "psUrl": "/game"
        },
        {
          "psDesc": "红包活动",
          "psId": 103,
          "psName": "活动",
          "psUrl": "/activity"
        },
        {
          "psDesc": "游戏玩家",
          "psId": 104,
          "psName": "玩家",
          "psUrl": "/player"
        },
        {
          "psDesc": "游戏直播监控",
          "psId": 105,
          "psName": "直播",
          "psUrl": "/live"
        },
        {
          "psDesc": "系统监控",
          "psId": 106,
          "psName": "监控",
          "psUrl": "/monitor"
        },
        {
          "psDesc": "系统设置",
          "psId": 107,
          "psName": "设置",
          "psUrl": "/setting"
        }
      ],
      "roleName": "super",
      "roleid": 1,
      "roleDesc":"管理员",
      "createDate":"2022-10-22"
    },
    {
      "authArrs": [
        {
          "psDesc": "基础数据统计分析",
          "psId": 101,
          "psName": "数据",
          "psUrl": "/data"
        },
        {
          "psDesc": "游戏基础配置",
          "psId": 102,
          "psName": "游戏",
          "psUrl": "/game"
        },
        {
          "psDesc": "红包活动",
          "psId": 103,
          "psName": "活动",
          "psUrl": "/activity"
        },
        {
          "psDesc": "游戏玩家",
          "psId": 104,
          "psName": "玩家",
          "psUrl": "/player"
        },
        {
          "psDesc": "游戏直播监控",
          "psId": 105,
          "psName": "直播",
          "psUrl": "/live"
        }
      ],
      "roleName": "admin",
      "roleid": 2,
      "roleDesc":"超级管理员",
      "createDate":"2022-10-22"
    }
  ]


export default [
  {
    url: '/api/role/list',
    timeout: 1000,
    method: 'get',
    response: ({ query }) => {
      // const { page = 1, pageSize = 10 } = query;
      // const list = roleList(Number(pageSize));
      return resultSuccess({
        // page: Number(page),
        // pageSize: Number(pageSize),
        // pageCount: 60,
        list:roleLists,
      });
    },
  },
];
